#define _CRT_SECURE_NO_WARNINGS 1

class Solution {
public:
    int countSum(int n)
    {
        int res = 0;
        while (n)
        {
            res += n % 10;
            n /= 10;
        }
        return res;
    }
    int countBalls(int lowLimit, int highLimit) {
        unordered_map<int, int> hash;
        for (int i = lowLimit; i <= highLimit; i++)
        {
            hash[countSum(i)]++;
        }
        int res = 0;
        for (auto& pair : hash)
        {
            res = max(pair.second, res);
        }
        return res;
    }
};